<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:if test="dictionary.dictionaryId==null"><s:text name="dictionary.add.title"/></s:if><s:else><s:text name="dictionary.edit.title"/></s:else></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
</head>
<body>
<div id="wrapper">
	<div class="curmb"><s:text name="your.site.position"/>:<a href="${ctx}/main.action"><s:text name="homepage"/></a><span>></span><s:text name="dictionary.title"/></div>
	<div class="listtit"><p><span><strong><s:if test="dictionary.dictionaryId==null"><s:text name="dictionary.add.title"/></s:if><s:else><s:text name="dictionary.edit.title"/></s:else></strong></span></p></div>
	<div class="listadd">
		<s:form action="dictionary-save" onsubmit="return chkform()">
		<s:hidden name="dicTypeBean.dicTypeId"/>
		<s:hidden name="dictionary.dictionaryId"/>
		<table class="addgrid">
			<tr>
				<th><s:text name="dictionary.cmsDictionaryType"/>:</th>
				<td><s:property value="dicTypeBean.dicTypeName" /></td>
			</tr>
			<tr>
				<th><s:text name="dictionary.dictionaryKey"/>:</th>
				<td><s:textfield name="dictionary.dictionaryKey" required="true" requiredposition="right" cssClass="txtin" maxlength="30"/></td>
			</tr>
			<tr>
				<th><s:text name="dictionary.dictionaryValue"/>:</th>
				<td><s:textfield name="dictionary.dictionaryValue" required="true" requiredposition="right" cssClass="txtin" maxlength="30"/></td>
			</tr>
			<tr>
				<th><s:text name="dictionary.memo"/>:</th>
				<td><s:textfield name="dictionary.memo" required="true" requiredposition="right" cssClass="txtin"/></td>
			</tr>
			<tr>
				<th><s:text name="dictionary.ord"/>:</th>
				<td><s:textfield name="dictionary.ord" required="true" requiredposition="right" cssClass="txtin"/></td>
			</tr>
			

			<tr>
				<th>&nbsp;</th>
				<td><s:submit value="%{getText('save')}" cssClass="btnlist2"/><s:reset value="%{getText('reset')}" cssClass="btnlist2"/><input type="button" value="<s:text name="return"/>" onclick="history.go(-1);" class="btnlist2"/></td>
			</tr>
		</table>
		</s:form>
	</div>
</div>
</body>
</html>
<script type="text/javascript" defer="defer">
	$(function(){
		$("input[name=dictionary.dictionaryKey]").blur(validate);
	});
	function validate(){
		if($("input[name=dictionary.dictionaryKey]").val()=='<s:property value="dictionary.dictionaryKey"/>'){
			$("#dictionary-save_0").attr("disabled",false);
			return false;
		}else{
			$.post("${ctx}/dictionary-validate.action?dictionary.dictionaryKey="+$("input[name=dictionary.dictionaryKey]").val()+"&dicTypeBean.dicTypeCode=<s:property value="dicTypeBean.dicTypeCode" />",function callback(data){
				if(data!='1'){
					$("#dictionary-save_0").attr("disabled",false);
				}else{
					alert("<s:text name='dictionary.isExist'/>");
					$("#dictionary-save_0").attr("disabled",true);
				}
			});
		}
	}
	function chkform(){
		var dicKey = $("input[name=dictionary.dictionaryKey]").val();
		var dicValue = $("input[name=dictionary.dictionaryValue]").val();
		if(dicKey==''){
			alert("<s:text name='dictionary.nullKey'/>");
			return false;
		}
		if(dicValue==''){
			alert("<s:text name='dictionary.nullValue'/>");
			return false;
		}
		
	}
</script>